﻿/**添加作业记录的加载处理**/
var NeedShowdivtrforTypeId = "";
function thisloadinByAdd() {
    $("#ftaskid").val(getUrlParam("urltaskid"));//任务ID
    $("#finfoid").val(getUrlParam("urlinfoid"));//地ID
    $("#finfofv1").val(getUrlParam("urlinfoname"));//编号
    $("#finfonv1").val(getUrlParam("urlinfomj"));//面积
    $("#finfodt1").val((new Date()).Format("yyyy-MM-dd hh:mm:ss"));//开始时间
    $("#finfodt2").val((addDate(new Date(), 1)).Format("yyyy-MM-dd hh:mm:ss"));//结束时间
    if (getUrlParam("urlworkinfotype") == "22") {
        $("#finfotype").val(2);
        $("#finfobytype1").val(2);
        $("#finfotypename").val("清园");
        $("#lb_worktypeshow").html("清园作业");

    }
    else if (getUrlParam("urlworkinfotype") == "33") {
        $("#finfotype").val(3);
        $("#finfobytype1").val(3);
        $("#finfotypename").val("打地");
        $("#lb_worktypeshow").html("打地作业");
    }
    else if (getUrlParam("urlworkinfotype") == "44") {
        $("#finfotype").val(4);
        $("#finfobytype1").val(4);
        $("#finfotypename").val("底肥");
        $("#lb_worktypeshow").html("底肥作业");
    }
    else if (getUrlParam("urlworkinfotype") == "55") {
        $("#finfotype").val(5);
        $("#finfobytype1").val(5);
        $("#finfotypename").val("整地");
        $("#lb_worktypeshow").html("整地作业");
    }
    else if (getUrlParam("urlworkinfotype") == "66") {
        $("#finfotype").val(6);
        $("#finfobytype1").val(6);
        $("#finfotypename").val("播种");
        $("#lb_worktypeshow").html("播种作业");
    }
    else if (getUrlParam("urlworkinfotype") == "77") {
        $("#finfotype").val(7);
        $("#finfobytype1").val(7);
        $("#finfotypename").val("水肥");
        $("#lb_worktypeshow").html("水肥作业");
    }
    else if (getUrlParam("urlworkinfotype") == "88") {
        $("#finfotype").val(8);
        $("#finfobytype1").val(8);
        $("#finfotypename").val("植保");
        $("#lb_worktypeshow").html("植保作业");
    }
    else if (getUrlParam("urlworkinfotype") == "99") {
        $("#finfotype").val(8);
        $("#finfobytype1").val(8);
        $("#finfotypename").val("育苗");
        $("#lb_worktypeshow").html("育苗作业");
    }
    else if (getUrlParam("urlworkinfotype") == "1010") {
        $("#finfotype").val(10);
        $("#finfobytype1").val(10);
        $("#finfotypename").val("选苗");
        $("#lb_worktypeshow").html("选苗作业");
    }
    else if (getUrlParam("urlworkinfotype") == "1111") {
        $("#finfotype").val(11);
        $("#finfobytype1").val(11);
        $("#finfotypename").val("采收");
        $("#lb_worktypeshow").html("采收作业");
    }
    else if (getUrlParam("urlworkinfotype") == "1212") {
        $("#finfotype").val(12);
        $("#finfobytype1").val(12);
        $("#finfotypename").val("报废");
        $("#lb_worktypeshow").html("报废作业");
    }
    else if (getUrlParam("urlworkinfotype") == "1313") {
        $("#finfotype").val(13);
        $("#finfobytype1").val(13);
        $("#finfotypename").val("移植");
        $("#lb_worktypeshow").html("移植作业");
    }

}
var loadworkggfv5fv7NeedLoad = 3;
function loadworkggfv5fv7(fv5, fv7, fv10)//加载工具
{
    //工具
    hcdoselbyPost("t1.id  as id,concat(t1.fv3,'-',t1.fv4) as name", "yw_baseinfo as t1  INNER JOIN yw_baseinfo as t2 on  t1.fv1=t2.id", "t1.type=8 and t1.maintype=8 and t1.databranchid=" + HCUser.HCUorg + " and t2.fv3 in(0," + $("#finfotype").val() + ")", "", "", "t1.id", function (data) {
        SetSelectWithArrayIdName("#finfofv5", data);
        loadworkggfv5fv7NeedLoad--;
        if (fv5) $("#finfofv5").val(fv5);
        if (loadworkggfv5fv7NeedLoad <= 0) {
            uiform.render('select');
            NeedShowdivtrforTypeId = "#divtrfor" + $("#finfotype").val();// 12  11 6 8 
            if ($(NeedShowdivtrforTypeId)) $(NeedShowdivtrforTypeId).show();
        }
    });
    //投入品工具
    hcdoselbyPost("t1.id  as id,concat(t1.producttype,'-',t1.name) as name", "herp_product as t1", "t1.databranchid=" + HCUser.HCUorg, "", "", "id", function (data) {
        SetSelectWithArrayIdName("#finfofv7", data);
        loadworkggfv5fv7NeedLoad--;
        if (fv7) $("#finfofv7").val(fv7);
        if (loadworkggfv5fv7NeedLoad <= 0) {
            uiform.render('select');
            NeedShowdivtrforTypeId = "#divtrfor" + $("#finfotype").val();// 12  11 6 8 
            if ($(NeedShowdivtrforTypeId)) $(NeedShowdivtrforTypeId).show();
        }
    });
    //防治对象
    hcdoselbyPost("t1.id  as id,concat(t1.fv1,'-',t1.fv2) as name", "yw_baseinfo as t1", "t1.type=9 and t1.maintype=9 and t1.databranchid=" + HCUser.HCUorg, "", "", "id", function (data) {
        SetSelectWithArrayIdName("#finfofv10", data);
        loadworkggfv5fv7NeedLoad--;
        if (fv10) $("#finfofv10").val(fv10);
        if (loadworkggfv5fv7NeedLoad <= 0) {
            uiform.render('select');
            NeedShowdivtrforTypeId = "#divtrfor" + $("#finfotype").val();// 12  11 6 8 
            if ($(NeedShowdivtrforTypeId)) $(NeedShowdivtrforTypeId).show();
        }
    });
}
// 日期，在原有日期基础上，增加days小时，默认增加1
function addDate(date, days) {
    if (days == undefined || days == '') {
        days = 1;
    }
    var date = new Date(date);
    date.setHours(date.getHours() + days);
    return date;
    //var month = date.getMonth() + 1;
    //var day = date.getDate();
    //return date.getFullYear() + '-' + getFormatDate(month) + '-' + getFormatDate(day);
}